package JobManagementUtils;

/*
This file is part of Open Grid Job Management System (OGJMS).

OGJMS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OGJMS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OGJMS.  If not, see <http://www.gnu.org/licenses/>.

The entire and newest source code can be found at http://code.google.com/p/ogjms/  
*/

import java.util.ArrayList;
import java.util.List;

public class FTResults{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private int nrFiles;
	private String fileOperationType="";
	
	private boolean pending=true;
	
	private List<String> filesFailed;
	private List<String> filesSuccessful;
	
	public FTResults(int nrFiles,String transferType){
		this.nrFiles=nrFiles;
		this.fileOperationType=transferType;
		this.filesFailed=new ArrayList<String>();
		this.filesSuccessful=new ArrayList<String>();
	}

	public void FTSucceded(String path){
		this.filesSuccessful.add(path);
	}
	public void FTFailed(String path){
		this.filesFailed.add(path);
	}
	
	public int getNrFilesFailed(){
		return this.filesFailed.size();
	}
	
	public int getNrFilesSuccessful(){
		return this.filesSuccessful.size();
	}
	
	public boolean isTransferSuccessful(){
		return (this.filesFailed.size()==0);
	}
	
	public String getFinalResults(){
		String msg="";
		msg+="\t Tipul Operatiei: "+this.fileOperationType+"\n";
		msg+="\t Transferate cu succes:"+filesSuccessful.size()+"\n";
		for (int i=0;i<filesSuccessful.size();i++){
			msg+="\t\t"+filesSuccessful.get(i)+"\n";
		}
		msg+="\t Netransferate:"+filesFailed.size()+"\n";
		for (int i=0;i<filesFailed.size();i++){
			msg+="\t\t"+filesFailed.get(i)+"\n";
		}
		if (filesFailed.size()>0){
			msg+="\n*** Va rugam verificati numele fisierelor si calea catre ele***\n";
		}
		return msg;
	}

	public void setPending(boolean pending) {
		this.pending = pending;
	}

	public boolean isPending() {
		return pending;
	}
}
